package org.wendu.wdoa.dep.api;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.wendu.wdoa.common.Result;
import org.wendu.wdoa.dep.dto.DepDto;
import org.wendu.wdoa.dep.dto.DepqueryDto;
import org.wendu.wdoa.dep.model.Department;
import org.wendu.wdoa.dep.service.DepartmentService;


import java.util.Map;

@Slf4j
@RestController
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;

    @GetMapping("/dep")
    public Result depList(DepqueryDto pageParam){
       Map<String ,Object> list = departmentService.getDepList(pageParam);
        return Result.OK(list);
    }
    @DeleteMapping("/deleteDepById/{d_id}")
    public Result deleteDepById(@PathVariable Integer d_id){
        departmentService.deleteDepId(d_id);
        return Result.OK();
    }
    @PostMapping("/addDep")
    public Result addDep(@RequestBody DepDto depDto){
        departmentService.addOneDep(depDto);
        return Result.OK();
    }
    @PostMapping("/updateDep")
    public Result updateDep(@RequestBody Department department){
        departmentService.updateDep(department);
        return Result.OK();
    }
    @DeleteMapping("/DelDep-Multi")
    public Result DepDoDelMulti(@RequestBody Integer[] d_ids){
        departmentService.DelDepMulti(d_ids);
        return Result.OK();
    }
}
